package com.epfuse.cloud.common.log;

import com.epfuse.cloud.admin.api.feign.RemoteLogService;
import com.epfuse.cloud.common.log.aspect.LogAspect;
import com.epfuse.cloud.common.log.event.LogListener;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;

@EnableAsync
@RequiredArgsConstructor
@ConditionalOnWebApplication
@Configuration(proxyBeanMethods = false)
public class LogAutoConfiguration {

	@Bean
	public LogListener sysLogListener(RemoteLogService remoteLogService) {
		return new LogListener(remoteLogService);
	}

	@Bean
	public LogAspect sysLogAspect() {
		return new LogAspect();
	}

}
